package cn.net.shuxing.yifu.common.dto;

import cn.net.shuxing.yifu.common.bean.BaseBean;
import cn.net.shuxing.yifu.common.bean.CashDealRecordDtoAdaptor;
import cn.net.shuxing.yifu.common.bean.CompanyBankCard;
import cn.net.shuxing.yifu.common.bean.RechargeHistory;
import cn.net.shuxing.yifu.common.constant.PaymentStatus;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.persistence.*;
import java.io.Serializable;

@Data
public class RechargeHistoryDto
{
	private Integer id;
	private String outTradeNo;
	private Integer userId;
	private String fee;
	private String subject;
	private String paymentStatus;
	private java.time.LocalDateTime createTime;
	private CompanyBankCard receiveCard;

	public static RechargeHistoryDto fromRechargeHistory(RechargeHistory rechargeHistory)
	{
		RechargeHistoryDto rechargeHistoryDto = new RechargeHistoryDto();
		BeanUtils.copyProperties(rechargeHistory,rechargeHistoryDto);
		String paymentStatus = rechargeHistoryDto.getPaymentStatus();
		if (paymentStatus.equals(PaymentStatus.UNPAID.name()))
		{
			paymentStatus = "未支付";
		}
		if (paymentStatus.equals(PaymentStatus.PAY_FAIL.name()))
		{
			paymentStatus = "支付失败";
		}
		if (paymentStatus.equals(PaymentStatus.ClOSED.name()))
		{
			paymentStatus = "已关闭";
		}
		if (paymentStatus.equals(PaymentStatus.PAID.name()))
		{
			paymentStatus = "已支付";
		}
		rechargeHistoryDto.setPaymentStatus(paymentStatus);
		rechargeHistoryDto.setReceiveCard(JSON.parseObject(rechargeHistory.getSubject(),CompanyBankCard.class));
		return rechargeHistoryDto;
	}
}

/*
{
	id:主键,
	outTradeNo:对外交易编号,
	orderNo:订单号,
	userId:充值用户id,
	fee:充值金额,
	subject:交易内容,
	paymentStatus:支付状态,
	deleted:是否已被删除，0表示未被删除，1表示已被删除,
	createTime:创建时间,
	updateTime:最新修改时间,
	callbackTime:回调时间,
	callbackContent:回调信息
}

*/
